package com.knowledge.graph.controller;

import com.knowledge.graph.model.vo.ResponseVO;
import com.knowledge.graph.model.vo.StatusCode;
import com.knowledge.graph.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@CrossOrigin
public class LoginController {

    @Resource
    private UserService userService;

    @PostMapping("/student/login")
    public ResponseVO login(@RequestParam("userName") String userName, @RequestParam("passWord") String passWord, HttpServletRequest httpServletRequest) {
        if (userName.isEmpty() || passWord.isEmpty()) {
            return new ResponseVO(StatusCode.FAIL_SELECT.getCode(), StatusCode.FAIL_SELECT.getMessage());
        }
        return userService.queryUser(userName, passWord,httpServletRequest);
    }

}
